package buffer;


import java.io.*;


public class BufferTest {
    public static void main(String[] args) throws IOException {

        FileInputStream inputStream = new FileInputStream("D:\\test\\a.java");//字节流
        //输入缓存流
        BufferedInputStream bufferedInput = new BufferedInputStream(inputStream);
        //输入
        FileOutputStream outputStream = new FileOutputStream("D:\\test\\b.java");
        BufferedOutputStream bufferedOutput = new BufferedOutputStream(outputStream);
        //拷贝功能
        int read;
        do {
            read = bufferedInput.read();
            bufferedOutput.write(read);
            bufferedInput.close();
            inputStream.close();
            bufferedOutput.close();
            outputStream.close();
        }
        while (read == -1);
        int len;
        byte[] buff = new byte[1024];
        while ((len = bufferedInput.read(buff)) != -1) {
            bufferedOutput.write(buff, 0, len);
        }
        bufferedOutput.flush();
        bufferedInput.close();
        inputStream.close();
        bufferedOutput.close();
        outputStream.close();
    }
}

